#! /usr/bin/env	python

# this script used to extract fasta files in fq file

import os
def fq2fasta(fqfile, fastafile):
	f = open(fqfile,'r')
	lists = f.readlines() 
	f2 = open(fastafile,'w')
	for i in xrange(0,len(lists),4):
		print >>f2, '>'+lists[i].replace(os.linesep,'')
		print >>f2, lists[i+1].replace(os.linesep,'')
	f.close()
	f2.close()

if __name__ == '__main__': 
	import sys, time
	if len(sys.argv) == 1:
		print "Usage:python fq2fasta.py fqfile fastafile"
	if len(sys.argv) ==3:
		starttime = time.time()
		fq2fasta(sys.argv[1],sys.argv[2])
		endtime = time.time()
		print "Done! Takes %f seconds" % (endtime-starttime)
		
